home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 May / macformat-024.iso / Shareware City / Developers / Kant Pro source Folder / Kant Pro 1.1 ƒ / Shell ƒ / graphics dispatch.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-21  |  9.5 KB  |  512 lines  |  [TEXT/MMCC]

  1. #include "graphics dispatch.h"
  2. #include "drag utilities.h"
  3. #include "window layer.h"
  4. #include "program globals.h"
  5. #include "edit functions.h"
  6. #include "text twiddling.h"
  7. #include "generic window handlers.h"
  8. #include "about.h"
  9. #include "about MSG.h"
  10. #include "other MSG window.h"
  11. #include "help.h"
  12. #include "kant main window.h"
  13. #include "kant build window.h"
  14.  
  15. enum DispatchError SetupWindowDispatch(short index, WindowPtr theWindow)
  16. {
  17.     Boolean            success=FALSE;
  18.     RgnHandle        hiliteRgn;
  19.     
  20.     SetWindowIndex(theWindow, index);
  21.     SetWindowTE(theWindow, 0L);
  22.     SetWindowVScrollBar(theWindow, 0L);
  23.     SetWindowHScrollBar(theWindow, 0L);
  24.     SetWindowIsDraggable(theWindow, FALSE);
  25.     SetWindowHiliteRgn(theWindow, 0L);
  26.     SetWindowOldClickLoopProc(theWindow, 0L);
  27.     
  28.     switch (index)
  29.     {
  30.         case kAboutWindow:
  31.             SetupTheAboutWindow(theWindow);
  32.             success=TRUE;
  33.             break;
  34.         case kAboutMSGWindow:
  35.             SetupTheAboutMSGWindow(theWindow);
  36.             success=TRUE;
  37.             break;
  38.         case kOtherMSGWindow:
  39.             SetupTheOtherMSGWindow(theWindow);
  40.             success=TRUE;
  41.             break;
  42.         case kHelpWindow:
  43.             SetupTheHelpWindow(theWindow);
  44.             success=TRUE;
  45.             break;
  46.         case kMainWindow:
  47.             SetupTheMainWindow(theWindow);
  48.             success=TRUE;
  49.             break;
  50.         case kBuildWindow:
  51.             SetupTheBuildWindow(theWindow);
  52.             success=TRUE;
  53.             break;
  54.     }
  55.     
  56.     if ((DragManagerAvailableQQ()) && (success) && (WindowIsDraggableQQ(theWindow)))
  57.     {
  58.         hiliteRgn=NewRgn();
  59.         SetWindowHiliteRgn(theWindow, hiliteRgn);
  60.         InstallTrackingHandler((DragTrackingHandler)MyTrackingHandler, theWindow, (void *)theWindow);
  61.         InstallReceiveHandler((DragReceiveHandler)MyReceiveDropHandler, theWindow, (void *)theWindow);
  62.     }
  63.     
  64.     return success ? kSuccess : kFailure;
  65. }
  66.  
  67. enum DispatchError ShutdownWindowDispatch(short index)
  68. {
  69.     switch (index)
  70.     {
  71.         case kAboutWindow:
  72.             ShutDownTheAboutWindow();
  73.             return kSuccess;
  74.         case kAboutMSGWindow:
  75.             ShutDownTheAboutMSGWindow();
  76.             return kSuccess;
  77.         case kOtherMSGWindow:
  78.             ShutDownTheOtherMSGWindow();
  79.             return kSuccess;
  80.         case kHelpWindow:
  81.             ShutDownTheHelpWindow();
  82.             return kSuccess;
  83.         case kMainWindow:
  84.             ShutDownTheMainWindow();
  85.             return kSuccess;
  86.         case kBuildWindow:
  87.             ShutDownTheBuildWindow();
  88.             return kSuccess;
  89.     }
  90.     
  91.     return kFailure;
  92. }
  93.  
  94. enum DispatchError OpenWindowDispatch(short index)
  95. {
  96.     WindowPtr        theWindow;
  97.     
  98.     theWindow=GetIndWindowPtr(index);
  99.     
  100.     switch (index)
  101.     {
  102.         case kAboutWindow:
  103.             OpenTheAboutWindow(theWindow);
  104.             return kSuccess;
  105.         case kAboutMSGWindow:
  106.             OpenTheMSGWindow(theWindow);
  107.             return kSuccess;
  108.         case kOtherMSGWindow:
  109.             OpenTheOtherMSGWindow(theWindow);
  110.             return kSuccess;
  111.         case kHelpWindow:
  112.             OpenTheHelpWindow(theWindow);
  113.             return kSuccess;
  114.         case kMainWindow:
  115.             OpenTheMainWindow(theWindow);
  116.             return kSuccess;
  117.         case kBuildWindow:
  118.             OpenTheBuildWindow(theWindow);
  119.             return kSuccess;
  120.     }
  121.     
  122.     return kFailure;
  123. }
  124.  
  125. enum DispatchError CloseWindowDispatch(short index)
  126. {
  127.     WindowPtr        theWindow;
  128.     
  129.     theWindow=GetIndWindowPtr(index);
  130.     
  131.     switch (index)
  132.     {
  133.         case kMainWindow:
  134.             if (CloseTheMainWindow(theWindow))
  135.                 return kSuccess;
  136.             else
  137.                 return kCancel;
  138.     }
  139.     
  140.     return kFailure;
  141. }
  142.  
  143. enum DispatchError DisposeWindowDispatch(short index)
  144. {
  145.     WindowPtr        theWindow;
  146.     Boolean            success=FALSE;
  147.     RgnHandle        hiliteRgn;
  148.     
  149.     theWindow=GetIndWindowPtr(index);
  150.     
  151.     switch (index)
  152.     {
  153.         case kAboutWindow:
  154.             DisposeTheAboutWindow(theWindow);
  155.             success=TRUE;
  156.             break;
  157.         case kOtherMSGWindow:
  158.             DisposeTheOtherMSGWindow(theWindow);
  159.             success=TRUE;
  160.             break;
  161.         case kHelpWindow:
  162.             DisposeTheHelpWindow(theWindow);
  163.             success=TRUE;
  164.             break;
  165.         case kMainWindow:
  166.             DisposeTheMainWindow(theWindow);
  167.             success=TRUE;
  168.             break;
  169.         case kBuildWindow:
  170.             DisposeTheBuildWindow(theWindow);
  171.             success=TRUE;
  172.             break;
  173.     }
  174.     
  175.     if ((DragManagerAvailableQQ()) && (success) && (WindowIsDraggableQQ(theWindow)))
  176.     {
  177.         RemoveTrackingHandler((DragTrackingHandler)MyTrackingHandler, theWindow);
  178.         RemoveReceiveHandler((DragReceiveHandler)MyReceiveDropHandler, theWindow);
  179.         hiliteRgn=GetWindowHiliteRgn(theWindow);
  180.         DisposeRgn(hiliteRgn);
  181.     }
  182.     
  183.     return success ? kSuccess : kFailure;
  184. }
  185.  
  186. enum DispatchError DrawWindowDispatch(short index, short theDepth)
  187. {
  188.     WindowPtr        theWindow;
  189.     
  190.     theWindow=GetIndWindowPtr(index);
  191.     
  192.     switch (index)
  193.     {
  194.         case kAboutMSGWindow:
  195.             DrawTheAboutMSGWindow(theWindow, theDepth);
  196.             return kSuccess;
  197.         case kHelpWindow:
  198.             DrawTheHelpWindow(theWindow, theDepth);
  199.             return kSuccess;
  200.     }
  201.     
  202.     return kFailure;
  203. }
  204.  
  205. enum DispatchError ChangeDepthDispatch(short index, short newDepth)
  206. {
  207.     WindowPtr        theWindow;
  208.     
  209.     theWindow=GetIndWindowPtr(index);
  210.     
  211.     switch (index)
  212.     {
  213.         case kAboutMSGWindow:
  214.             ChangeDepthTheAboutMSGWindow(theWindow, newDepth);
  215.             return kSuccess;
  216.     }
  217.     
  218.     return kFailure;
  219. }
  220.  
  221. enum DispatchError CopybitsDispatch(short index, WindowPtr offscreenWindow)
  222. {
  223.     WindowPtr        theWindow;
  224.     
  225.     theWindow=GetIndWindowPtr(index);
  226.     
  227.     switch (index)
  228.     {
  229.         case kOtherMSGWindow:
  230.         case kMainWindow:
  231.         case kBuildWindow:
  232.             GenericCopybits(theWindow, offscreenWindow, WindowIsActiveQQ(theWindow));
  233.             return kSuccess;
  234.     }
  235.     
  236.     return kFailure;
  237. }
  238.  
  239. enum DispatchError IdleWindowDispatch(short index, Point mouseLoc)
  240. {
  241.     WindowPtr        theWindow;
  242.     
  243.     theWindow=GetIndWindowPtr(index);
  244.     
  245.     switch (index)
  246.     {
  247.         case kMainWindow:
  248.             GenericIdleInWindow(theWindow, mouseLoc);
  249.             return kSuccess;
  250.     }
  251.     
  252.     return kFailure;
  253. }
  254.  
  255. enum DispatchError ActivateWindowDispatch(short index)
  256. {
  257.     WindowPtr        theWindow;
  258.     
  259.     theWindow=GetIndWindowPtr(index);
  260.     
  261.     switch (index)
  262.     {
  263.         case kOtherMSGWindow:
  264.         case kMainWindow:
  265.         case kBuildWindow:
  266.             GenericActivate(theWindow);
  267.             return kSuccess;
  268.     }
  269.     
  270.     return kFailure;
  271. }
  272.  
  273. enum DispatchError DeactivateWindowDispatch(short index)
  274. {
  275.     WindowPtr        theWindow;
  276.     
  277.     theWindow=GetIndWindowPtr(index);
  278.     
  279.     switch (index)
  280.     {
  281.         case kOtherMSGWindow:
  282.         case kMainWindow:
  283.         case kBuildWindow:
  284.             GenericDeactivate(theWindow);
  285.             return kSuccess;
  286.     }
  287.     
  288.     return kFailure;
  289. }
  290.  
  291. enum DispatchError GrowWindowDispatch(short index)
  292. {
  293.     WindowPtr        theWindow;
  294.     
  295.     theWindow=GetIndWindowPtr(index);
  296.     
  297.     switch (index)
  298.     {
  299.         case kOtherMSGWindow:
  300.         case kMainWindow:
  301.             GenericResizeControls(theWindow, 0);
  302.             return kSuccess;
  303.         case kBuildWindow:
  304.             GenericResizeControls(theWindow, 1000);
  305.             return kSuccess;
  306.     }
  307.     
  308.     return kFailure;
  309. }
  310.  
  311. enum DispatchError ZoomWindowDispatch(short index)
  312. {
  313.     WindowPtr        theWindow;
  314.     
  315.     theWindow=GetIndWindowPtr(index);
  316.     
  317.     switch (index)
  318.     {
  319.         case kOtherMSGWindow:
  320.         case kMainWindow:
  321.             GenericResizeControls(theWindow, 0);
  322.             return kSuccess;
  323.         case kBuildWindow:
  324.             GenericResizeControls(theWindow, 1000);
  325.             return kSuccess;
  326.     }
  327.     
  328.     return kFailure;
  329. }
  330.  
  331. enum DispatchError GetGrowSizeDispatch(short index, Rect *sizeRect)
  332. {
  333.     WindowPtr        theWindow;
  334.     
  335.     theWindow=GetIndWindowPtr(index);
  336.     
  337.     switch (index)
  338.     {
  339.         case kOtherMSGWindow:
  340.         case kMainWindow:
  341.         case kBuildWindow:
  342.             GenericGetGrowSize(theWindow, sizeRect);
  343.             return kSuccess;
  344.     }
  345.     
  346.     return kFailure;
  347. }
  348.  
  349. enum DispatchError KeyDownDispatch(short index, unsigned char theChar)
  350. {
  351.     WindowPtr        theWindow;
  352.     
  353.     theWindow=GetIndWindowPtr(index);
  354.     
  355.     switch (index)
  356.     {
  357.         case kAboutWindow:
  358.             KeyDownInAboutWindow(theWindow, theChar);
  359.             return kSuccess;
  360.         case kOtherMSGWindow:
  361.             GenericKeyPressedInWindow(theWindow, theChar);
  362.             return kSuccess;
  363.         case kHelpWindow:
  364.             KeyPressedInHelpWindow(theWindow, theChar);
  365.             return kSuccess;
  366.         case kMainWindow:
  367.             if (!GenericKeyPressedInWindow(theWindow, theChar))
  368.                 KeyPressedInMainWindow(theWindow, theChar);
  369.             return kSuccess;
  370.         case kBuildWindow:
  371.             if (!GenericKeyPressedInWindow(theWindow, theChar))
  372.                 KeyPressedInBuildWindow(theWindow, theChar);
  373.             return kSuccess;
  374.     }
  375.     
  376.     return kFailure;
  377. }
  378.  
  379. enum DispatchError MouseUpDispatch(short index, Point thePoint)
  380. {
  381.     WindowPtr        theWindow;
  382.     
  383.     theWindow=GetIndWindowPtr(index);
  384.     
  385.     switch (index)
  386.     {
  387.         case kBuildWindow:
  388.             MouseUpInBuildWindow(theWindow, thePoint);
  389.             return kSuccess;
  390.     }
  391.     
  392.     return kFailure;
  393. }
  394.  
  395. enum DispatchError MouseDownDispatch(short index, Point thePoint)
  396. {
  397.     WindowPtr        theWindow;
  398.     
  399.     theWindow=GetIndWindowPtr(index);
  400.     
  401.     switch (index)
  402.     {
  403.         case kAboutWindow:
  404.             MouseDownInAboutWindow(theWindow, thePoint);
  405.             return kSuccess;
  406.         case kOtherMSGWindow:
  407.             GenericMouseClickedInWindow(theWindow, thePoint, FALSE);
  408.             return kSuccess;
  409.         case kHelpWindow:
  410.             MouseClickedInHelpWindow(theWindow, thePoint);
  411.             return kSuccess;
  412.         case kMainWindow:
  413.             GenericMouseClickedInWindow(theWindow, thePoint, TRUE);
  414.             return kSuccess;
  415.         case kBuildWindow:
  416.             MouseClickedInBuildWindow(theWindow, thePoint);
  417.             return kSuccess;
  418.     }
  419.     
  420.     return kFailure;
  421. }
  422.  
  423. enum DispatchError UndoDispatch(short index)
  424. {
  425.     switch (index)
  426.     {
  427.     }
  428.     
  429.     return kFailure;
  430. }
  431.  
  432. enum DispatchError CutDispatch(short index)
  433. {
  434.     WindowPtr        theWindow;
  435.     
  436.     theWindow=GetIndWindowPtr(index);
  437.     
  438.     switch (index)
  439.     {
  440.         case kMainWindow:
  441.             GenericCut(theWindow);
  442.             return kSuccess;
  443.             break;
  444.     }
  445.     
  446.     return kFailure;
  447. }
  448.  
  449. enum DispatchError CopyDispatch(short index)
  450. {
  451.     WindowPtr        theWindow;
  452.     
  453.     theWindow=GetIndWindowPtr(index);
  454.     
  455.     switch (index)
  456.     {
  457.         case kMainWindow:
  458.             GenericCopy(theWindow);
  459.             return kSuccess;
  460.     }
  461.     
  462.     return kFailure;
  463. }
  464.  
  465. enum DispatchError PasteDispatch(short index)
  466. {
  467.     WindowPtr        theWindow;
  468.     
  469.     theWindow=GetIndWindowPtr(index);
  470.     
  471.     switch (index)
  472.     {
  473.         case kMainWindow:
  474.             PasteInMainWindow(theWindow);
  475.             return kSuccess;
  476.     }
  477.     
  478.     return kFailure;
  479. }
  480.  
  481. enum DispatchError ClearDispatch(short index)
  482. {
  483.     WindowPtr        theWindow;
  484.     
  485.     theWindow=GetIndWindowPtr(index);
  486.     
  487.     switch (index)
  488.     {
  489.         case kMainWindow:
  490.             GenericClear(theWindow);
  491.             return kSuccess;
  492.     }
  493.     
  494.     return kFailure;
  495. }
  496.  
  497. enum DispatchError SelectAllDispatch(short index)
  498. {
  499.     WindowPtr        theWindow;
  500.     
  501.     theWindow=GetIndWindowPtr(index);
  502.     
  503.     switch (index)
  504.     {
  505.         case kMainWindow:
  506.             GenericSelectAll(theWindow);
  507.             return kSuccess;
  508.     }
  509.     
  510.     return kFailure;
  511. }
  512.